翻訳と辞書
Words near each other
・ Unique Sweets
・ Unique Theater
・ Unique user
・ Unique visitor
・ Unique Whips
・ Unique World Records
・ Unique, Iowa
・ Unique-event polymorphism
・ Uniquely colorable graph
・ Uniquely inversible grammar
・ Uniqueness case
・ Uniqueness Database File
・ Uniqueness quantification
・ Uniqueness theorem
・ Uniqueness theorem for Poisson's equation
Uniqueness type
・ UniquePhones
・ UNIR
・ Unirac
・ Uniracers
・ Uniradze
・ Uniramia
・ Uniramodes
・ Unirea
・ Unirea (newspaper)
・ Unirea Ion Roată
・ Unirea National College
・ Unirea National College (Brașov)
・ Unirea National College (Târgu Mureș)
・ Unirea River


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Uniqueness type : ウィキペディア英語版
Uniqueness type

In computing, a unique type guarantees that an object is used in a single-threaded way, with at most a single reference to it. If a value has a unique type, a function applied to it can be optimized to update the value in-place in the object code. Such in-place updates improve the efficiency of functional languages while maintaining referential transparency. Unique types can also be used to integrate functional and imperative programming.
==Introduction==
Uniqueness typing is best explained using an example. Consider a function readLine that reads the next line of text from a given file:
function readLine(File f) returns String
return line where
String line = doImperativeReadLineSystemCall(f)
end
end
Now doImperativeReadLineSystemCall reads the next line from the file using an OS-level system call which has the side effect of changing the current position in the file. But this violates referential transparency because calling it multiple times with the same argument will return different results each time as the current position in the file gets moved. This in turn makes readLine violate referential transparency because it calls doImperativeReadLineSystemCall.
However, using uniqueness typing, we can construct a new version of readLine that is referentially transparent even though it's built on top of a function that's not referentially transparent:
function readLine2(unique File f) returns (unique File, String)
return (differentF, line) where
String line = doImperativeReadLineSystemCall(f)
File differentF = newFileFromExistingFile(f)
end
end
The unique declaration specifies that the type of f is unique; that is to say that f may never be referred to again by the caller of readLine2 after readLine2 returns, and this restriction is enforced by the type system. And since readLine2 does not return f itself but rather a new, different file object differentF, this means that it's impossible for readLine2 to be called with f as an argument ever again, thus preserving referential transparency while allowing for side effects to occur.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Uniqueness type」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.